#include "moz_mechanize.hpp"
#include "moz_repl.hpp"

moz_mechanize::moz_mechanize(const char* _profile_filename, unsigned int _profile_no, const char* _moz_config_filename):
_profile_dispatch(_profile_filename, _profile_no)
{

	moz_repl repl;
	repl.init_from(_moz_config_filename);
	_connection_str = repl.connection_str();

	popen_file =NULL;
}

void moz_mechanize::dispatch() 
{
	_profile_dispatch.dispatch(&popen_file, _connection_str);
}

moz_mechanize::~moz_mechanize()
{
	if(popen_file != NULL)
	{
#ifdef WIN32
		_pclose(popen_file);
#else
		pclose(popen_file);
#endif
	}
}
